package com.itheima_03;

import java.util.Scanner;

/*
    评委打分：有6个评委打分（1-100），去掉一个最高分去掉一个最低分，
    取其他4个分数的平均值为最终得分（不考虑小数部分）
*/
public class GetScore {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[6];
        int maxscore = arr[0];
        int minscore = arr[0];
        int sumscore = 0;
        int score = 0;
        for (int i = 0; i < arr.length; i++) {
            while (true) {
                System.out.println("请第" + (i +1) + "位评委打分（1-100）：");
                int score1 = sc.nextInt();
                if(score1 < 0 || score1 > 100) {
                    System.out.println("您输入的分数有误。");
                } else {
                    arr[i] = score1;
                    break;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            if (maxscore < arr[i]) {
                maxscore = arr[i];
            }
            if (minscore > arr[i]) {
                minscore = arr[i];
            }
        }
        for (int i = 0; i < arr.length; i++) {
            sumscore += arr[i];
        }
        score = (sumscore - maxscore - minscore) / (arr.length - 2);
        System.out.println("score:" + score);
    }
}
